package com.gking.centerSystem.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gking.centerSystem.AOP.annotationUtil.desensitizeData.DesensitizeData;
import com.gking.centerSystem.AOP.annotationUtil.desensitizeData.SensitizedTypeEnum;
import com.gking.centerSystem.common.Result;
import com.gking.centerSystem.entity.dao.PagingQueryLogsRecordDao;
import com.gking.centerSystem.entity.LogsRecord;
import com.gking.centerSystem.service.LogsRecord.LogsRecordService;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/logsRecord")
public class LogsRecordController {

    @Autowired
    private LogsRecordService logsRecordService;


    /**
     * 添加日志记录
     *
     * @param logsRecord 日志信息
     */
    private void addLogsRecord(LogsRecord logsRecord) {
    }


    /**
     * 分页获取日志记录列表
     *
     * @param page         分页页码
     * @param size         分页大小
     * @param conditionDto 条件
     * @return s
     */
    @DesensitizeData({
            @DesensitizeData.Field(field = "requestBody", type = SensitizedTypeEnum.ALL),
            @DesensitizeData.Field(field = "ipAddress", type = SensitizedTypeEnum.IP),
            @DesensitizeData.Field(field = "accessUserId", type = SensitizedTypeEnum.COMMON),
    })
    @RequiresPermissions("CS:manager:query:logs")
    @PostMapping("/getPageLogsRecordList")
    public Result<Page> getPageLogsRecordList(@RequestParam Integer page, @RequestParam Integer size,
                                              @RequestBody PagingQueryLogsRecordDao conditionDto) {
        return logsRecordService.getPageLogsRecordList(page, size, conditionDto);
    }


}
